<?php

use GatewayWorker\Lib\Gateway;

/**
 * --------------------------------------------------
 * Copyright © 2018 PHP游戏项目学习交流群：820621745 版权所有
 *
 * 功能描述：
 *
 * 创建标识：Created by Zyc On 2018/8/11 18:59
 *
 * 修改标识：
 * 修改描述：
 *---------------------------------------------------
 */

class RouteManager
{
    /**
     * 消息转发
     */
    public static function onMessage($client_id, $message)
    {
        $message=json_decode($message,true);
        $routeMsg = array(
            "client_id"     => $client_id,                //客户端ID
            "head"          => $message["head"],          //请求码
            "msg"           => $message["msg"],           //客户端消息
        );

        //心跳忽略
        if($routeMsg["head"] == 0X100000)
        {
            return;
        }

        //公共服务器
        if($routeMsg["head"] >= 0X200001 && $routeMsg["head"] <= 0X2FFFFF)
        {
            \Channel\Client::publish(MsgEvents::$PublicServerMsg,$routeMsg);
            return;
        }

        //服务器1
        if($routeMsg["head"] >= 0X300001 && $routeMsg["head"] <= 0X3FFFFF)
        {
            \Channel\Client::publish(MsgEvents::$DDZServerMsg,$routeMsg);
            return;
        }

    }
}